package com.airwallex.strategy.util;

import com.airwallex.strategy.CalculateStrategy;
import com.airwallex.strategy.impl.*;

import java.util.HashMap;
import java.util.Map;

public class CalculateStrategyFactory {
    //存放策略映射，扩展运算符在此添加策略即可
    private static Map<String, CalculateStrategy> strategyMap = new HashMap<String, CalculateStrategy>(){{
        put("+", new AddStrategy());
        put("-", new SubtractStrategy());
        put("*", new MultiplyStrategy());
        put("/", new DivideStrategy());
        put("sqrt", new SqrtStrategy());
        put("undo", new UndoStrategy());
        put("clear", new ClearStrategy());
//        put("sin", new SineStrategy());
//        put("cos", new CosineStrategy());
//        put("!", new FactorialStrategy());
    }};


    //根据运算符查找运算策略
    public static CalculateStrategy getCalculateStrategy(String oper) {
        CalculateStrategy strategy = strategyMap.get(oper);
        return strategy;
    }
}
